package com.pro.controller;

import com.pro.mapper.JsMicrocircleCommentMapper;
import com.pro.pojo.JsComment;
import com.pro.pojo.JsGoodsComment;
import com.pro.pojo.JsMicrocircle;
import com.pro.pojo.JsonData;
import com.pro.service.JsMicrocircleCommentService;
import com.pro.utils.SensitiveWordsUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * ClassName:JsMicrocircleCommentController
 * Package:com.pro.controller
 * Description:
 *
 * @Date:2022/1/18 18:46
 * @Author: XJR
 */
@RequestMapping("/MicrocirclComment")
@RestController
public class JsMicrocircleCommentController {

    @Autowired
    private JsMicrocircleCommentService service;

    /**
     * @Description:
     * @Author: XJR
     * @Date: 2022/1/18
     * @Content:前台按钮微圈数量
     */
    @RequestMapping("/selectBeforeCountAll")
    public JsonData selectBeforeCountAll(String status,Integer type){
        status = status!=null&&!status.equals("")?"%"+status+"%":"%%";
        Integer integer = service.selectBeforeCountAll(status, type);
        return integer!=null?JsonData.buildSuccess(integer):JsonData.buildError("服务器发生错误");
    };

    /**
     * @Description:
     * @Author: XJR
     * @Date: 2022/1/18
     * @Content:前台table中的数量
     */
    @RequestMapping("/selectBeforeCountToday")
    public JsonData selectBeforeCountToday(Integer type, String status, String commentDate){
        status = status!=null&&!status.equals("")?"%"+status+"%":"%%";
        Integer integer1 = service.selectBeforeCountAll(status,type);
        Integer integer2 = service.selectBeforeCountToday(type, status, commentDate);
        JsGoodsComment comment = new JsGoodsComment();
        comment.setGoodsCountAllComment(integer1);
        comment.setCountCommentsToday(integer2);
        return comment!=null?JsonData.buildSuccess(comment):JsonData.buildError("服务器发生错误");
    };

    /**
     * @Description:
     * @Author: XJR
     * @Date: 2022/1/18
     * @Content:前台layuiTable中的数据
     */
    @RequestMapping("/selectBeforeTable")
    public JsonData selectBeforeTable(Integer type, String status, Integer limit, Integer page){
        status = status!=null&&!status.equals("")?"%"+status+"%":"%%";
        List<JsComment> jsComments = service.selectBeforeTable(type, status, limit, page);
        Integer integer = service.selectBeforeCountAll(status, type);
        return jsComments!=null?JsonData.buildSuccess(jsComments,integer):JsonData.buildError("服务器发生错误");
    };

    /**
     * @Description:
     * @Author: XJR
     * @Date: 2022/1/18
     * @Content:查看前台用户微圈
     */
    @RequestMapping("/selectBeforeJsMicrocircle")
    public JsonData selectBeforeJsMicrocircle(Integer type, Integer id){
        JsMicrocircle jsMicrocircle = service.selectBeforeJsMicrocircle(type, id);
        return jsMicrocircle!=null?JsonData.buildSuccess(jsMicrocircle):JsonData.buildError("服务器发生错误");
    };

    /**
     * @Description:
     * @Author: XJR
     * @Date: 2022/1/19
     * @Content:通过Id查询前台评论详情
     */
    @RequestMapping("/selectBeforeCommentById")
    public JsonData selectBeforeCommentById(Integer commodityId,Integer type){
        List<JsComment> jsComments = service.selectBeforeCommentById(commodityId, type);
        List<JsComment> listFilter = SensitiveWordsUtil.getListFilter(jsComments);
        return listFilter!=null?JsonData.buildSuccess(listFilter):JsonData.buildError("服务器发生错误");
    };

    /**
     * @Description:
     * @Author: XJR
     * @Date: 2022/1/19
     * @Content:管理人员按钮微圈数量
     */
    @RequestMapping("/selectUserCountAll")
    public JsonData selectUserCountAll(String status,Integer type){
        status = status!=null&&!status.equals("")?"%"+status+"%":"%%";
        Integer integer = service.selectUserCountAll(status, type);
        return integer!=null?JsonData.buildSuccess(integer):JsonData.buildError("服务器发生错误");
    };

    /**
     * @Description:
     * @Author: XJR
     * @Date: 2022/1/18
     * @Content:管理人员table中的数量
     */
    @RequestMapping("/selectUserCountToday")
    public JsonData selectUserCountToday(Integer type,String status,String commentDate){
        status = status!=null&&!status.equals("")?"%"+status+"%":"%%";
        Integer integer1 = service.selectUserCountAll(status, type);
        Integer integer2 = service.selectUserCountToday(type, status, commentDate);
        JsGoodsComment comment = new JsGoodsComment();
        comment.setGoodsCountAllComment(integer1);
        comment.setCountCommentsToday(integer2);
        return comment!=null?JsonData.buildSuccess(comment):JsonData.buildError("服务器发生错误");
    };

    /**
     * @Description:
     * @Author: XJR
     * @Date: 2022/1/19
     * @Content:管理人员layuiTable中的数据
     */
    @RequestMapping("/selectUserTable")
    public JsonData selectUserTable(Integer type,String status,Integer limit,Integer page){
        status = status!=null&&!status.equals("")?"%"+status+"%":"%%";
        List<JsComment> jsComments = service.selectUserTable(type, status, limit, page);
        Integer integer = service.selectUserCountAll(status,type);
        return jsComments!=null?JsonData.buildSuccess(jsComments,integer):JsonData.buildError("服务器发生错误");
    };

    /**
     * @Description:
     * @Author: XJR
     * @Date: 2022/1/19
     * @Content:查看管理人员用户微圈
     */
    @RequestMapping("/selectUserJsMicrocircle")
    public JsonData selectUserJsMicrocircle(Integer type, Integer id){
        JsMicrocircle jsMicrocircle = service.selectUserJsMicrocircle(type, id);
        return jsMicrocircle!=null?JsonData.buildSuccess(jsMicrocircle):JsonData.buildError("服务器发生错误");
    };

    /**
     * @Description:
     * @Author: XJR
     * @Date: 2022/1/19
     * @Content:通过Id查询管理人员评论详情
     */
    @RequestMapping("/selectUserCommentById")
    public JsonData selectUserCommentById(Integer commodityId,Integer type){
        List<JsComment> jsComments = service.selectUserCommentById(commodityId, type);
        List<JsComment> listFilter = SensitiveWordsUtil.getListFilter(jsComments);
        return listFilter!=null?JsonData.buildSuccess(listFilter):JsonData.buildError("服务器发生错误");
    };
}
